package com.blacksheep.mtm.service.Impl;

import com.blacksheep.mtm.dao.TbOrderItemMapper;
import com.blacksheep.mtm.dto.OrderItemDto;
import com.blacksheep.mtm.pojo.common.DataTablesResult;
import com.blacksheep.mtm.pojo.manager.TbOrderItem;
import com.blacksheep.mtm.service.OrderItemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderItemServiceImpl implements OrderItemService {

    @Autowired
    private TbOrderItemMapper orderItemMapper;

    @Override
    public DataTablesResult getList(int draw, int start, int length, String search, String minDate, String maxDate, String orderCol, String orderDir) {

        DataTablesResult result=new DataTablesResult();
        //分页
        PageHelper.startPage(start/length+1,length);
        List<OrderItemDto> list = orderItemMapper.selectList("%"+search+"%",minDate,maxDate,orderCol,orderDir);
        PageInfo<OrderItemDto> pageInfo=new PageInfo<>(list);

        result.setRecordsFiltered((int)pageInfo.getTotal());
        result.setDraw(draw);
        result.setData(list);
        return  result;
    }

    @Override
    public int deleteBatch(String[] ids) {
        return 0;
    }

    @Override
    public List<TbOrderItem> getListByOrderId(String orderId) {
        return null;
    }
}
